﻿using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;

namespace Marketplace.Mvc.Content.Handlers
{
    /// <summary>
    /// Summary description for ImageHandler
    /// </summary>
    public class ImageHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/jpg";
            var image = Image.FromFile(context.Server.MapPath("~/Content/image.jpg"));
            var stream = new MemoryStream();
            image.Save(stream, ImageFormat.Jpeg);

            context.Response.BinaryWrite(stream.ToArray());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}